home *** CD-ROM | disk | FTP | other *** search
/ IBM InfoROM for OS/2 Beta 1995 January / IBM InfoROM for OS2 Beta 1-1995.ISO / testcert / storage / function / cdrom / search.cmd < prev    next >
Encoding:
Text File  |  1994-05-04  |  1.1 KB  |  44 lines

  1. /*
  2. ** SEARCH.CMD
  3. ** Rexx command file to search for a keyword in a set files and put
  4. ** the result into an output file.
  5. ** arg(1) = keyword to search for
  6. ** arg(2) = file mask to look for keyword in
  7. ** arg(3) = filename to put results in
  8. */
  9.  
  10. Search:
  11.  
  12. call RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
  13. call RxFuncAdd 'SysFileTree',   'RexxUtil', 'SysFileTree'
  14. call RxFuncAdd 'SysFileSearch', 'RexxUtil', 'SysFileSearch'
  15.  
  16. /*
  17. ** Query for the number of log files generated.
  18. */
  19. call SysFileTree arg(2), files., 'FO'
  20.  
  21. /*
  22. ** Delete any old results file.
  23. */
  24. call SysFileDelete arg(3)
  25.  
  26. /*
  27. ** Search each log file for the keyword: ERROR and copy located lines to
  28. ** the results file.
  29. */
  30. if files.0 > 0 then
  31. do i = 1 to files.0
  32.    call SysFileSearch arg(1), files.i, results., 'C'
  33.    if results.0 > 0 then
  34.    do
  35.       call stream arg(3), 'command', 'open write'
  36.       do j = 1 to results.0
  37.          /* SAY files.i results.j */
  38.          call lineout arg(3), files.i results.j
  39.       end
  40.       call stream arg(3), 'command', 'close'
  41.    end
  42. end
  43. return
  44.